package net.sourceforge.peers;

import java.util.Arrays;

/**
 * @Author Mr.Yan
 * @create 2022/4/14 18:55
 * @description:
 */
public class InsertSort {
    public static void main(String[] args) {
        int[] num = {3,44,38,5,47,15,36,26,27,2,46,4,19,50,48} ;
        int j;

        for (int i = 1; i < num.length ; i++) {

            int temp = num[i];

            for (j = i - 1;j >= 0&&num[j] > temp ;j--)  //比较的次数 比较条件
            {
                num[j + 1] = num[j];
            }
            num[j + 1] = temp;

        }
        System.out.println("最终的排序结果："+Arrays.toString(num));
    }

}

